package mylib.dir;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.StringTokenizer;

/**
 * Created with IntelliJ IDEA.
 * User: 1
 * Date: 16.07.12
 * Time: 18:45
 * To change this template use File | Settings | File Templates.
 */
public class FastInputReader {
    private StringTokenizer tokenizer;
    public BufferedReader reader;

    public FastInputReader(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
        tokenizer = null;
    }

    public String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException e) {
            return "-1";
        }
        return tokenizer.nextToken();
    }

    public String readLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            return "-1";
        }
    }

    public String nextString() {
        return next();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public BigInteger nextBigInteger() {
        return new BigInteger(next());
    }

    public BigDecimal nextBigDecimal() {
        return new BigDecimal(next());
    }

    public char nextChar() {
        try {
            return (char) reader.read();
        } catch (IOException e) {
            return 0;
        }
    }
}
